package test;

import static org.junit.Assert.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import dsa.LinkedList;


public class JonColabellaTest {

	LinkedList list = new LinkedList();
	
	@Before
	public void setUp() throws Exception {
		list.addFirst("five");
		list.addFirst("four");
		list.addFirst("three");
		list.addFirst("two");
		list.addFirst("one");
		list.addLast("six");
		list.addLast("seven");
		list.addLast("eight");
		list.addLast("nine");
		list.addLast("ten");
	}
	
	@Test
	public void sizeTest(){
		assertTrue(list.size() == 10);
	}
	
	@Test
	public void getTest(){
		assertTrue(list.get(4).equals("five"));
		assertTrue(list.getFirst().equals("one"));
		assertTrue(list.getLast().equals("ten"));
		assertFalse(list.get(4).equals("nine"));
	}
	
	@Test
	public void setTest(){
		list.set(5, "five 2.0");
		assertTrue(list.get(5).equals("five 2.0"));
	}
	
	@Test
	public void removeTest(){
		list.remove(5);
		list.removeLast();
		list.removeFirst();
		
		assertTrue(list.get(5).equals("eight"));
		assertTrue(list.getLast().equals("nine"));
		assertTrue(list.getFirst().equals("two"));
		assertTrue(list.size() == 7);
	}
	
	@Test
	public void containsTest(){
		assertTrue(list.contains("two") == true);
		assertTrue(list.indexOf("two") == 1);
		assertTrue(list.indexOf("Rice") == -1);
		list.remove(4);
		assertFalse(list.contains("five") == true);
	}
	
	@Test
	public void toArrayTest(){
		Object array [] = list.toArray();
		assertTrue(array.length == 10);
		for(int i = 0; i < array.length; i++)
			assertTrue(array[i].equals(list.get(i)));
	}
	
	@Test
	public void cloneTest(){
		LinkedList cloneList = (LinkedList)list.clone();
		for(int i = 0; i > cloneList.size(); i++)
			cloneList.get(i).equals(list.get(i));		
	}

	@After
	public void tearDown() throws Exception {
		
	}
}
